home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-03-06 | 2.3 KB | 63 lines | [TEXT/GEOL] |
- Item forwarded by PERRY.G to PIRO CATHERS PHIL.TH
-
- Item 1915439 23-Sept-90 08:39PDT
-
- From: MIKE.VILOT ObjectWare, Michael Vilot,PRT
-
- To: MM.XOBJ MacroMind, XObject Support,PRT
-
- cc: CPLUS.APPLE$ C++ Interest List--Apple Employees
- CPLUS.DEV$ C++ Interest List--Developers
- TIM.SWIHART Swihart, Tim
-
- Sub: Re> C++ bug,missing feature
-
- Haim,
-
- It's rather difficult to diagnose the problem you are encountering
- without more specific information. I have been able to use private
- derivation successfully, so I can suggest that the implementation is
- not at fault.
-
- Perhaps the error is arising from a missing base class constructor.
- Typically, a derived class constructor forgets to propagate arguments to
- an appropriate base constructor, and that implies the base's default
- constructor has to be invoked. If the base class does not provide any
- constructors, then a default memberwise constructor can be synthesized.
- However, if other constructors exist, then the default will _not_ be
- synthesized.
-
- I typically provide default constructor, copy constructor, and assignment
- operators for classes with non-trivial initialization semantics. When I
- derive classes from these, I often need to provide derived constructors
- that propagate arguments correctly:
-
- class Base {
- public:
- Base() { /* default initialization */ }
- Base(const Base& b) { /* copy initialization */ }
- Base& operator=(const Base& b) { /* destructor & copy semantics */ }
- ...
- };
-
- class Derived : private Base {
- public:
- Derived() /* Base() invoked here */ { /* derived default init */ }
- Derived(const Derived& d) : Base(d) { /* any additional copying */ }
- Base& operator=(const Derived& d) { /*stuff*/ return Base::operator=(d); }
- ...
- };
-
- Note that the implicit conversion rules of a derived reference to base
- reference ensure that invoking the base class' copy constructor and assignment
- operator are type-correct.
-
- As an aside, ``The Annotated Reference Manual'' describes the language
- implemented in cfront 2.1 (and derivatives). There are several changes
- not supported in 2.0-based translators, such as Apple's current offering.
-
- Hope this helps,
-
- Mike
-
-